import Vue from 'vue'
import App from './App.vue'
import './assets/main.css';
import GoodsList from './pages/goods-list.vue';
import GoodsSearch from './pages/goods-search.vue';
import MyInfo from './pages/my-info.vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const routes = [
  {
    path: '/goods-list',
    component: GoodsList,
  },
  {
    path: '/goods-search',
    component: GoodsSearch,
  },
  {
    path: '/my-info',
    component: MyInfo,
  },
];

const router = new VueRouter({
  routes,
});

router.beforeEach((to, from, next) => {
  console.log(to);
  console.log(from);
  console.log(next);
  if (to.path === '/goods-list'  ) {
    alert('没权限')
    next=false
  }else {
    next()
  }
})

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App),
}).$mount('#app')